<?php
/**
 * Copyright (C) 2007-2008  madoqua.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/**
 * setup.php
 *
 * will start the madoqua install after setting up url rewriting
 *
 * Norm Rawks! \ó/
 *
 * @category    Madoqua
 * @package     Install
 */

//set up include path
$includePath = realpath(getcwd()) . '/madoqua_private/library/';
set_include_path($includePath . PATH_SEPARATOR . get_include_path() );

require_once('Zend/Loader/Autoloader.php');
Zend_Loader_Autoloader::getInstance()->registerNamespace('Madoqua_');

$viewFile = 'Zend/View.php';

if (($fh = @fopen($viewFile, 'r', true))) {
    //we can open the view file directly
    //ZF is in the path, go mirmo!
    require_once $viewFile;

} else {
    //it isn't in the path, but don't panic, madoqua can come with ZF! \ó/

    $privateViewFile = $includePath . $viewFile;
    //view file in madoqua itself (ZF included)

    if (($fh = @fopen($privateViewFile, 'r', true))) {
        require_once $privateViewFile;
    } else {
        die('Zend_View was not found in your path, nor in your Madoqua package.');
    }
}

/** installer */
require_once 'Madoqua/Install.php';

$install = new Madoqua_Install();
echo $install->execute()->getBody();
//let's install this dikdik 8^]